Skip to content

Recover selected capture reads when the runtime directory is unavailable - #9109

Open
loopx-agent wants to merge 1 commit into
mainfrom
codex/context-read-runtime-unavailable-20261120
Open

loopx-agent wants to merge 1 commit into
mainfrom
codex/context-read-runtime-unavailable-20261120

Conversation

@loopx-agent

Copy link
Copy Markdown
Collaborator

Goal And Delivered Outcome

A saved capture can pass its digest check while the local Effect runtime has no usable temporary directory. In that case, a selected read used to report that the capture could not be read. The full reader could still return the exact original bytes.

The runtime request now returns its existing typed failure when temporary-directory resolution fails before dispatch. After a verified capture reaches selection planning, a startup failure also returns a recovery_command for the original selector, offset, digest and reader route. Restoring runtime access allows that read to finish.

Author Declaration

Written by model_agent (OpenAI Codex, GPT-6).

Implemented against

The captured context read and recovery contract at the tested base. Required work context

Criterion Disposition Evidence
Verify the capture before interpreting a selection. Implemented The same complete source is readable under a simulated temporary-directory failure. Tampered source checks pass.
Report when the selection runtime cannot start. Implemented The real CLI returns runtime_request_failed with a temporary-directory diagnosis. The public result excludes the failing private path.
Keep the original selection and cursor during recovery. Implemented Direct, continuation and reference-file fixtures retry the returned command after the fault is lifted. They finish with the expected selected value and the original source bytes.
Preserve read-only authority on the recovery route. Implemented The generated retry calls quota context-read with the original capture identity and selector.

Validation

Tested revision f11cb6e6c880c0358b6ff9d0a5ccd781cc233125 against base 8e9a28a866da06cc6fd63e78709910fe35dad564. The inputs were synthetic and the tests used isolated runtime directories.

Check kind Result Evidence
real_entrypoint passed Three quota context-read cases cover a direct selection, an existing page cursor and an immutable capture reference. The retry uses the actual TypeScript selector.
regression_parity passed The base reports a capture read failure after temporary-directory resolution fails. Both original fault tests fail their diagnostic assertion on base and pass on head.
integration passed 50 selected reader and runtime cases, including digest, pinned selection, cursor recovery and permission checks.
integration failed Two Markdown host-permission assertions expect a status bullet and receive the fenced Turn Envelope. The same two assertions fail on the base, this head and a local composition with #9084 at 35c9b103540bcd5a26e0be6bb1756a57e67ffa2b.
static passed Ruff for changed Python, public boundary and RFC checks. 24 standard premerge checks passed.
regression_parity passed The disk-bounded baseline exporter from #9103 ran the same CLI differential on the exact base and author head. All 98 rows matched the applicable regression checks.
integration blocked Stock premerge stopped its CLI differential during the baseline checkout because local disk space was exhausted. The disk-bounded run above completed that comparison. #9103
integration not_run Full suite, hosted qualification and installed Host verification. Independent review is pending.

The fault test simulates an unavailable temporary directory. The recovery check runs the normal reader after restoring access.

Frontend / Visual Evidence

UI impact is none.

Type of Change

  • Bug fix
  • Test update

LoopX Area

  • Control plane

The commit carries DCO sign-off. Validation disclosure guidance

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · gpt-6.2-sol · OpenAI (runtime_reported, max)

Request changes conclusion (author-owned PR; GitHub blocks formal self-review)

[P2] 选读失败响应超出调用方的字节上限

同一个显式 754 字节上限正常可读,候选的启动失败 JSON 却输出 863 字节。按上限截取实测输出后 JSON 无法解析,调用方拿不到恢复命令。 在此错误分支上用实际序列化大小守住显式上限。完整命令放不下时返回完整短诊断,指明恢复后重试原参数。已有短 reference 足以重试时可沿用。 复现时,可以先在 --page-bytes 256 下读取能到 EOF 的短选读,将其完整输出字节数加 8 设为上限,再让 tempfile.gettempdir() 抛出 ENOSPC。 相关代码

动机 / Motivation

通过 CLI 或原生宿主工具选读当前捕获的 Agent 需要收到可解析的诊断。 原捕获通过摘要验证后,运行时目录仍可能无法访问。恢复指令应让读者修复运行时后继续原请求。 候选给出 runtime_request_failed 和重试命令。恢复后,实际 TypeScript 选读返回原值,旧式 pinned reference 从第 256 个 UTF-8 字节继续,嵌套 list 恢复后与普通路径相同。 本次验收范围是原捕获的只读故障和恢复。

改动思路 / Approach

沿用 Python capture reader、现有 TypeScript 选择规划和 EffectRuntimeStartupError。先验证源,再由同一调用生成恢复命令,合适的修复边界是序列化出口。修改选读启动故障的反馈。完整直接读和已有可直接解析地址走原路径。一次真实选读故障分别在正常、故障和恢复后进入同一 CLI 解析入口,核对实际字节、精确选中值和源摘要。 基线和候选共用文档、选择器和 UTF-8 输出测量。

具体改动 / Changes

精确 head f11cb6e6c880c0358b6ff9d0a5ccd781cc233125,diff base 8e9a28a866da06cc6fd63e78709910fe35dad564,5 个文件 +92/-1。逐项复核 原捕获验证、选读诊断与精确恢复、错误响应预算。验收约定

关键代码讲解

  • 定位器初始化错误进入既有类型,新诊断未带出故障中的私有路径。源码
  • 正常重试保持原文件、选中值和游标,旧式 pinned reference 从 256 字节处续读,已解析地址在故障时可直接读。源码
  • PR 的三种用例均在 12,000 字节内检查最终值。独立复验另外检查了错误输出能否遵守更紧的调用预算。源码

对主干的风险 / Risks

93 项读回和 reference 用例通过。3 个新增故障用例在精确基线均因缺少 diagnostic_code 失败。共享运行时相邻套件两侧均为 40 通过、3 项同样失败。 test_failed_guard_keeps_host_recovery_without_runtime_presentation 的两个 Markdown 参数收到 fenced Turn Envelope,test_common_command_dispatch_defines_one_effect_runtime_request 的替身不接受 registry_was_configured。 测试从正常 CLI dispatcher 发出真实请求,故障注入仅替换临时目录解析。已安装宿主、真实可见历史和全套件未实测。

语义与 CI 对齐

Ruff、diff 和 6 个 premerge 直接检查通过,标准套件 18/19 个选中检查通过。stock CLI 对照因本机磁盘不足没能创建基线工作树。独立用 #9103 的窄源导出重跑同一 probe、fixture 和验收规则,两精确提交的 98 行对照通过。 这里验证的是本地匹配执行。

我的整体评价 / Verdict

保留摘要检查和原游标重试。请让有限预算内的调用方在目录故障时也收到完整的 JSON。复验应使用同一上限完成正常读取、诊断和恢复,并核对重试的选中值和游标。

English verdict: REQUEST_CHANGES. The runtime diagnostic and same-capture recovery work. Under a valid 754-byte limit, the new startup error emits 863 bytes and becomes invalid JSON when the caller applies that limit. Bound the failure response and cover this case at the CLI.

result["recovery"] = ("Resolve the reported runtime failure, then retry reading the same digest-bound capture; "
"no guard, admission or spend was performed.")
if runtime_read_retry is not None:
result["recovery_command"] = runtime_read_retry

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里追加完整重试命令后直接返回,跳过了序列化预算检查。相同参数的正常响应为 746 字节,显式上限为 754 字节。临时目录故障时实际输出为 863 字节,截在上限会丢失可解析 JSON。请在此错误分支保住上限,并补一个正常可读但完整失败命令放不下的 CLI 用例。短错误可以引导用户恢复运行时后重试原参数。

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant